package com.yakisoft.jublish;

import org.junit.Test;
import static org.junit.Assert.*;

import java.io.StringReader;
import java.io.IOException;


public class SiteConfigTest {
	@Test
	public void testParser() throws IOException {
		StringReader reader = new StringReader("server:myserver.com\n" +
				"user:root\n" +
				"password:mypassword\n" +
				"destination-folder:/web/test\n" +
				"source-folder:/web/test\n" +
				"ignore:*.bak\n" +
				"ignore:*.tmp\n" +
				"ignore:*.svn\n" +
				"file:index.html aabbccdd\n" +
				"file:images eeddccbb");
		
		SiteConfig config = new SiteConfig(reader);

		assertEquals("myserver.com", config.server);
		assertEquals("root", config.username);
		assertEquals("mypassword", config.password);
		assertEquals("/web/test", config.destinationFolder);
		assertEquals("/web/test", config.sourceFolder);


		assertTrue(config.isIgnored("test.bak"));
		assertTrue(config.isIgnored("test.tmp"));
		assertTrue(config.isIgnored("/test/.svn"));
		assertFalse(config.isIgnored("test.txt"));

		assertEquals(2, config.files.size());
		assertTrue(config.files.containsKey("index.html"));
		assertEquals("aabbccdd", config.files.get("index.html"));
	}
}
